namespace ASPNET.UserControls
{
    using ASPNET.StarterKit.IssueTracker.BusinessLogicLayer;
    using System;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class PickQuery : UserControl
    {
        private QueryCollection _DataSource;
        private bool _DisplayDefault;
        [AccessedThroughProperty("dropQueries")]
        private DropDownList _dropQueries;
        private object designerPlaceholderDeclaration;

        public PickQuery()
        {
            base.Init += new EventHandler(this.Page_Init);
            this._DisplayDefault = false;
        }

        public override void DataBind()
        {
            this.dropQueries.Items.Clear();
            this.dropQueries.DataSource = this._DataSource;
            this.dropQueries.DataTextField = "Name";
            this.dropQueries.DataValueField = "Id";
            this.dropQueries.DataBind();
            if (this._DisplayDefault)
            {
                this.dropQueries.Items.Insert(0, new ListItem("-- Select Query --", "0"));
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        public string CssClass
        {
            get
            {
                return this.dropQueries.CssClass;
            }
            set
            {
                this.dropQueries.CssClass = value;
            }
        }

        public QueryCollection DataSource
        {
            get
            {
                return this._DataSource;
            }
            set
            {
                this._DataSource = value;
            }
        }

        public bool DisplayDefault
        {
            get
            {
                return this._DisplayDefault;
            }
            set
            {
                this._DisplayDefault = value;
            }
        }

        protected virtual DropDownList dropQueries
        {
            get
            {
                return this._dropQueries;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._dropQueries != null)
                {
                }
                this._dropQueries = value;
                if (this._dropQueries != null)
                {
                }
            }
        }

        public int ItemCount
        {
            get
            {
                return this.dropQueries.Items.Count;
            }
        }

        public int SelectedValue
        {
            get
            {
                return int.Parse(this.dropQueries.SelectedValue);
            }
            set
            {
                this.dropQueries.SelectedValue = value.ToString();
            }
        }
    }
}

